import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../AppConfig/Config.dart';

class DirectComplaints extends StatefulWidget {
  const DirectComplaints({super.key});

  @override
  State<DirectComplaints> createState() => _DirectComplaintsState();
}

class _DirectComplaintsState extends State<DirectComplaints> {
  List typeList=["司机把货拖走","司机加价收费","司机迟到/爽约","货物损失","回单问题"];
  List chooseList=[];
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text("运单投诉",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body: Column(
        children: [
          Expanded(
              child: ListView(
                children: [
                  Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                    ),
                    padding: EdgeInsets.only(left: 13.w,top: 15.h,bottom: 16.h),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          children: [
                            Image.asset("lib/Images/OrderList/运单投诉手机icon.png",width: 18.w,height: 18.h,),
                            SizedBox(width: 7.w,),
                            Text("手机号",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                            Text("111****5555",style: TextStyle(color: MyColors.themeColor),),
                          ],
                        ),
                        SizedBox(height: 8.h,),
                        Container(height: 1.h,color: MyColors.backgreyColor,),
                        SizedBox(height: 15.h,),
                        Row(
                          children: [
                            Text("物流路线",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("苏州市吴中区-苏州市吴中区",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("对方姓名",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("张**",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("运单编号",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("111122223333444444",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("运单状态",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("已完成",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("运单时间",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("2023-05-23 11:55:25",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                      ],
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    padding: EdgeInsets.only(top: 13.h,bottom: 13.h),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                    ),
                    child: Column(
                      children: [
                        Row(
                          children: [
                            Container(width: 4.w,height: 16.h,color: MyColors.themeColor,),
                            SizedBox(width:14.w ,),
                            Text("请选择投诉类型",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height: 10.h,),
                        SizedBox(height: 5.h,child: Container(color: MyColors.backgreyColor,),),
                        SizedBox(height: 10.h,),
                        Padding(
                          padding: const EdgeInsets.only( left: 18),
                          child: Wrap(
                            spacing: 25.w, // 两个Container之间的水平间距
                            runSpacing: 11.h, // 行与行之间的垂直间距
                            children: typeList.map((length) {
                              bool? isSelected = chooseList.contains(length);

                              return GestureDetector(
                                onTap: () {
                                  // 处理点击事件
                                  setState(() {
                                    if (isSelected) {
                                      //如果已经被选中，则移除
                                      chooseList.remove(length);

                                    } else  {
                                      // 如果未被选中且未达到最大选择数量，则添加
                                      chooseList.add(length);

                                    }
                                  });
                                },
                                child: Container(
                                  width: 120.w, // Container宽度
                                  height: 34.0, // Container高度，使其成为正方形
                                  padding: EdgeInsets.only(left: 8.w,right: 8.w),
                                  decoration: BoxDecoration(
                                    border: Border.all(
                                      color: isSelected ?MyColors.themeColor:MyColors.backgreyColor , // 边框颜色
                                      width: 1.0, // 边框宽度
                                    ),
                                    color: isSelected ? Color.fromRGBO(251, 236, 228, 1) : MyColors.backgreyColor, // 根据状态决定颜色
                                    borderRadius: BorderRadius.circular(3.0), // 设置Container的圆角
                                  ),
                                  child: Center(
                                    child: Text(
                                      length,
                                      style: TextStyle(
                                        fontSize: 13.sp,
                                        color: isSelected ?MyColors.themeColor:Colors.black, // 文字颜色为白色
                                      ),
                                    ),
                                  ),
                                ),
                              );
                            }).toList(),
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    padding: EdgeInsets.only(top: 13.h,bottom: 13.h),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                    ),
                    child: Column(
                      children: [
                        Row(
                          children: [
                            Container(width: 4.w,height: 16.h,color: MyColors.themeColor,),
                            SizedBox(width:14.w ,),
                            Text("投诉内容",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        Container(
                          margin: EdgeInsets.only(left: 18.w,right: 18.w,top: 10.h),
                          child: BrnInputText(
                            maxHeight: 200,
                            minHeight: 30,
                            minLines: 1,
                            maxLength: 140,
                            bgColor: MyColors.backgreyColor,
                            textInputAction: TextInputAction.newline,
                            maxHintLines: 20,
                            hint: '必填，请输入您要投诉的内容',
                            padding: EdgeInsets.fromLTRB(20, 10, 20, 14),
                            onTextChange: (text) {
                              print(text);

                              setState(() {});
                            },
                            onSubmit: (text) {
                              print(text);
                            },
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),
          ),
          Container(
            height: 85.h,
            color: Colors.white,
            padding: EdgeInsets.only(top: 10.h,bottom: 40.h),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                BrnSmallOutlineButton(
                  width: screenSize.width/2-20.w,
                  radius: 30,
                  title: '发起投诉',
                  textColor: MyColors.themeColor,
                  lineColor: MyColors.themeColor,
                  fontWeight: FontWeight.w600,
                  onTap: () {
                    BrnToast.show('次按钮', context);
                  },
                ),
                SizedBox(width: 10.w,),
                BrnSmallMainButton(
                  width: screenSize.width/2-20.w,
                  radius: 30,
                  title: '联系货主',
                  textColor: Colors.white,
                  bgColor: MyColors.themeColor,
                  fontWeight: FontWeight.w600,
                  onTap: () {
                    BrnToast.show('录需求信息', context);
                  },
                )
              ],
            ),
          )
        ],
      )


    );
  }
}
